<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h2>style绑定</h2>
      <!-- 允许使用对象的写法 -->
      <!-- key是css的属性，value是标量或者表达式 -->

      <!-- 如果属性是有连字符的，需要转成小驼峰或者加上引号 -->
      <p :style="{color: color, 'font-size': size + 'px' }">style绑定</p>

      <p :style="{fontSize: size + 'px'}">hello</p>
      <button @click="fn">btn</button>

      <div
        class="box"
        :style="{ transform: 'translateX(' + tst + 'px)' }"
      ></div>
      <button @click="tst += 30">btn2</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          color: "red",
          size: 20,
          tst: 30,
        },
        methods: {
          fn() {
            this.size++;
          },
        },
      });
    </script>
  </body>
</html>
